#include<bits/stdc++.h>
#define ls (p<<1)
#define rs ((p<<1)+1)
#define mid ((L+R)>>1)
using namespace std;
namespace IO
{
	template<typename T>
	void read(T &_x){_x=0;int _f=1;char ch=getchar();while(!isdigit(ch)) _f=(ch=='-'?-1:_f),ch=getchar();while(isdigit(ch)) _x=_x*10+(ch^48),ch=getchar();_x*=_f;}
	template<typename T,typename... Args>
	void read(T &_x,Args&...others){Read(_x);Read(others...);}
	const int BUF=20000000;char buf[BUF],to,stk[32];int plen;
	#define pc(x) buf[plen++]=x
	#define flush(); fwrite(buf,1,plen,stdout),plen=0;
	template<typename T>inline void print(T x){if(!x){pc(48);return;}if(x<0) x=-x,pc('-');for(;x;x/=10) stk[++to]=48+x%10;while(to) pc(stk[to--]);}
}
using namespace IO;
const int N = 1e6+10,M = 1e6+2;
int n,l,r,id,mi,mx,sum,k,x,y;
char ch;
struct w
{
	int ans,mx,ad;
	priority_queue<int>p,p1,P,P1;//shan chu xu yao shuang dui shan chu
	//p:zuo duan dian wei i,zui xiao you duan dian
	//p1:zui da you zuo duan dian
}c[N<<2];
inline void push(int p)
{
	c[ls].mx += c[p].ad,c[ls].ad += c[p].ad;
	c[rs].mx += c[p].ad,c[rs].ad += c[p].ad;
	c[p].ad = 0;
}
void build(int p,int L,int R)
{
	c[p].ans = 1e9;
	if(L == R) return;
	build(ls,L,mid),build(rs,mid+1,R);
}
void change_l(int p,int l,int L,int R)
{
	if(id == 1) c[p].p1.push(-k);
	else c[p].P1.push(-k);
	while(!c[p].P1.empty() && c[p].p1.top() == c[p].P1.top()) c[p].P1.pop(),c[p].p1.pop();
	if(L == l && R == l) return;
	if(l <= mid) change_l(ls,l,L,mid);
	else change_l(rs,l,mid+1,R);
	c[p].ans = min(c[ls].ans,c[rs].ans);
	if(!c[rs].p1.empty() && !c[ls].p.empty()) x = -c[rs].p1.top(),y = c[ls].p.top(),c[p].ans = min(c[p].ans,x-y+1);
}
void change_r(int p,int l,int L,int R)
{
	if(id == 1) c[p].p.push(k);
	else c[p].P.push(k);
	while(!c[p].P.empty() && c[p].p.top() == c[p].P.top()) c[p].P.pop(),c[p].p.pop();
	if(L == l && R == l) return;
	if(l <= mid) change_r(ls,l,L,mid);
	else change_r(rs,l,mid+1,R);
	c[p].ans = min(c[ls].ans,c[rs].ans);
	if(!c[rs].p1.empty() && !c[ls].p.empty()) x = -c[rs].p1.top(),y = c[ls].p.top(),c[p].ans = min(c[p].ans,x-y+1);
}
void change1(int p,int L,int R)
{
	if(l <= L && R <= r)
	{
		c[p].mx += k,c[p].ad += k;
		return;
	}
	if(c[p].ad != 0) push(p);
	if(l <= mid) change1(ls,L,mid);
	if(mid < r) change1(rs,mid+1,R);
	c[p].mx = max(c[ls].mx,c[rs].mx);
}
int query_l(int p,int L,int R)
{
	if(L == R) return p;
	if(c[p].ad != 0) push(p);
	if(c[ls].mx == sum) return query_l(ls,L,mid);
	else return query_l(rs,mid+1,R);
}
int query_r(int p,int L,int R)
{
	if(L == R) return p;
	if(c[p].ad != 0) push(p);
	if(c[rs].mx == sum) return query_r(rs,L,mid);
	else return query_r(ls,mid+1,R);
}
signed main()
{
	freopen("stone.in","r",stdin);
	freopen("stone.out","w",stdout);
	read(n);
	build(1,1,M);
	while(n--)
	{
		cin >> ch; read(l),read(r); r--;
		if(ch == 'A')
		{
			sum++;
			id = 1; k = r,change_l(1,l,1,M); k = l,change_r(1,r,1,M);//dai hao jia ru
			k = 1,change1(1,1,M);
		}
		else
		{
			sum--;
			id = 2; k = r,change_l(1,l,1,M); k = l,change_r(1,r,1,M);//shan chu  
			k = -1,change1(1,1,M);
		}
		l = query_l(1,1,M);
		if(c[l].mx != sum) print(c[1].ans),pc('\n');
		else 
		{
			r = query_r(1,1,M);
			print(-c[l].p1.top()-c[r].p.top()+1),pc('\n');
		}
	}
	flush();
	return 0;
}
